package com.xunsiya.module.base;

import net.minidev.json.annotate.JsonIgnore;

import java.io.Serializable;
import java.time.ZonedDateTime;

/**
 * (填写类功能描述)
 *
 * @author panjun
 * @version 1.0
 *          <p>
 *          <p>修订人		修订时间			描述信息
 *          <p>-----------------------------------------------------
 *          <p>panjun		2018/10/31		初始创建
 */
public class DataEntity implements Serializable {
    private static final long serialVersionUID = -5519222682984900319L;

    /** 创建者 */
    @JsonIgnore
    protected String createdBy;

    /** 创建日期 */
    @JsonIgnore
    protected ZonedDateTime createdDate = ZonedDateTime.now();

    /** 更新者 */
    @JsonIgnore
    protected String updatedBy;

    /** 更新日期 */
    @JsonIgnore
    protected ZonedDateTime updatedDate = ZonedDateTime.now();

    /** 删除标记（0：正常；1：删除；） */
    @JsonIgnore
    protected DeleteFlag status;

    /**
     * 新增前置方法
     * @param userName
     */
    public void prePersist(String userName) {
        this.status = DeleteFlag.NORMAL;
        this.createdBy = userName;
        this.updatedBy = createdBy;
    }

    /**
     * 新增前置方法
     * @param userName
     */
    public void prePersistNoId(String userName) {
        this.status = DeleteFlag.NORMAL;
        this.createdBy = userName;
        this.updatedBy = createdBy;
    }

    /**
     * 更新前置方法
     * @param userName
     */
    public void preUpdate(String userName) {
        this.updatedDate = ZonedDateTime.now();
        this.updatedBy = userName;
    }

    public DataEntity() {
        super();
        //  this.delFlag = DeleteFlag.NORMAL;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public ZonedDateTime getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(ZonedDateTime createdDate) {
        this.createdDate = createdDate;
    }

    public String getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    public ZonedDateTime getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(ZonedDateTime updatedDate) {
        this.updatedDate = updatedDate;
    }
}
